package cn.stylefeng.guns.modular.ws.sso.action;

import cn.stylefeng.guns.modular.ws.sso.proxy.pullSyncUserApiImpl.Exception;
import cn.stylefeng.guns.modular.ws.sso.proxy.pullSyncUserApiImpl.PullSyncUserApiImplStub;
import org.apache.axis2.AxisFault;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.rmi.RemoteException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
@RequestMapping("/api")
public class SysnPerson {

    public static void main(String[] args) {
        try {
            PullSyncUserApiImplStub stub = new PullSyncUserApiImplStub();
/*
            PullSyncUserApiImplStub.GetPersonDataE perSon = new PullSyncUserApiImplStub.GetPersonDataE() ;
            PullSyncUserApiImplStub.GetPersonData param = new PullSyncUserApiImplStub.GetPersonData() ;
            PullSyncUserApiImplStub.RequestPersonModel requestPersonModelparam = new PullSyncUserApiImplStub.RequestPersonModel() ;
            requestPersonModelparam.setKey("11AAC64B2052093A3D77C0A419680C7F0AC066D1F790AE9B4ABD58C26ADDCA5E3A018528");
            requestPersonModelparam.setPageNum("1");
            param.setArg0(requestPersonModelparam);
            perSon.setGetPersonData(param);

            PullSyncUserApiImplStub.GetPersonDataResponseE dataResponse =  stub.getPersonData(perSon) ;
            PullSyncUserApiImplStub.GetPersonDataResponse d = dataResponse.getGetPersonDataResponse() ;
            PullSyncUserApiImplStub.ResultPersons queryPersonModel  =  d.get_return() ;
            PullSyncUserApiImplStub.PersonModel[] list_ResultUserModel = queryPersonModel.getRetList() ;
            for(PullSyncUserApiImplStub.PersonModel Model : list_ResultUserModel){
                System.out.println("名称:"+Model.getName()+"--"+Model.getBirthdate());
                SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
                if(!"".equals(Model.getBirthdate())&& Model.getBirthdate() != null){
                    System.out.println("444444");
                    System.out.println("acount:"+df.parse(Model.getBirthdate()));

                }

            }*/

            PullSyncUserApiImplStub.GetOrgDataE  orgDataE = new PullSyncUserApiImplStub.GetOrgDataE() ;
            PullSyncUserApiImplStub.GetOrgData  orgData = new  PullSyncUserApiImplStub.GetOrgData() ;
            PullSyncUserApiImplStub.RequestOrgModel orgModel = new PullSyncUserApiImplStub.RequestOrgModel() ;
            orgModel.setKey("11AAC64B2052093A3D77C0A419680C7F0AC066D1F790AE9B4ABD58C26ADDCA5E3A018528");
            orgModel.setDeptFlag("1");
            int y= 2 ;
            for (int i=1;i<y;i++){
                orgModel.setPageNum(String.valueOf(i));
                orgData.setArg0(orgModel);
                orgDataE.setGetOrgData(orgData);

                PullSyncUserApiImplStub.GetOrgDataResponseE orgDataResponseE = stub.getOrgData(orgDataE) ;
                PullSyncUserApiImplStub.GetOrgDataResponse orgDataResponse = orgDataResponseE.getGetOrgDataResponse();
                PullSyncUserApiImplStub.ResultOrgs resultOrgs = orgDataResponse.get_return() ;
                PullSyncUserApiImplStub.OrgModel[] orgModels = resultOrgs.getRetList() ;
                for(PullSyncUserApiImplStub.OrgModel Model : orgModels){
                    System.out.println("Model.getTreeLevelNum():"+Model.getTreeLevelNum()+":dept:"+Model.getDeptName());
                    if(Model.getTreeLevelNum()!=null){
                        if(Integer.parseInt(Model.getTreeLevelNum()) == 1){
                            //System.out.println("-------");

                        }
                    }else{
                            System.out.println("++++++++");

                    }

                }
                if("1".equals(resultOrgs.getHaseNext())){
                    y = y + 1 ;
                }

            }

        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        } /*catch (ParseException e) {
            e.printStackTrace();
        }*/
    }
}
